
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><?php echo $title;?></title>
    <!-- 设置缩放 -->
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
    <meta name="format-detection" content="telephone=no" />
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- icon -->
    <link rel="shortcut icon" href="<?php echo ADMIN_ICO_PIC;?>" type="image/x-icon"/>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SYS_LINK;?>admin/css/content.css?v=<?php echo V_CSSJS;?>" />
    <style>
        .con_box .form_box .selectw100{width:137px;}
        .form_item input.input130{width:130px;}
    </style>
</head>
<body>
<div class="con_box">
    <div class="titleH18">修改功能权限</div>
    <form class="form_box">
        <input type="hidden" name="id" value="<?php echo isset($info['id']) ? $info['id'] : '';?>">
        <div class="form_item">
            <label>菜单</label>
            <select name="menu_id" id="menu_id" class="">
                <option value="0">ALL</option>
                <?php
                if(isset($classlist)) {
                    foreach ($classlist as $v) {
                        if ($v['status'] == 2) {
                            $level = $v['level']*2;
                            $str = str_pad("",$level, '-',STR_PAD_LEFT );
                            $fontb = $v['fid'] == 0 ? 'fontb' : '';
                            $act = isset($info['menu_id']) && $v["id"] == $info['menu_id'] ? 'act' : '';
                            $selected = isset($info['menu_id']) && ($v["id"] == $info['menu_id'] || $v["setpath"] == $info['menu_id']) ? 'selected="selected"' : '';
                            $selectId = $v['setflag'] == 1 ? $v['id'] : $v['setpath'];
                            echo '<option value="' . $selectId . '" '.$selected.' class="'.$fontb.' '.$act.'">' .$str .' '. $v["menuname"] . '</option>';
                        }
                    }
                }
                if(isset($classlistFuns)){
                    foreach($classlistFuns as $k=>$v){
                        $act = isset($info['menu_id']) && $k == $info['menu_id'] ? 'act' : '';
                        $selected = isset($info['menu_id']) && $k == $info['menu_id'] ? 'selected="selected"' : '';
                        echo '<option value="'.$k.'" class="fontb '.$act.'" '.$selected.'>'.$v.'</option>';
                    }
                }
                ?>
            </select>
            <!--<input type="text" name="menu_name" id="menu_name" value="<?php /*isset($info['menu_id']) && $info['menu_id'] && !is_numeric($info['menu_id']) ? $info['menu_id'] : '';*/?>" autocomplete="off" class="input130" placeholder="控制器名">-->
            <i class="hint">* (必选)选择菜单或者填写</i>
        </div>
        <div class="form_item">
            <label>功能</label>
            <input type="text" name="title" value="<?php echo isset($info['title']) ? $info['title'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (必填)</i>
        </div>
        <div class="form_item">
            <label>编码</label>
            <input type="text" name="funcode" value="<?php echo isset($info['funcode']) ? $info['funcode'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (必填)</i>
        </div>
        <div class="form_item">
            <label>类型</label>
            <select name="types" id="types">
                <?php
                if(isset($powerTypeArr)) {
                    foreach ($powerTypeArr as $k=>$v) {
                        $selected = isset($info['types']) && $k == $info['types'] ? 'selected="selected"' : '';
                        echo '<option value="' . $k . '" '.$selected.'>' . $v . '</option>';
                    }
                }
                ?>
            </select>
            <i class="hint">* (必选),控制器名默认其他</i>
        </div>
        <div class="form_item">
            <label>标注</label>
            <select name="flag">
                <?php
                if(isset($powerTypeFlags)) {
                    foreach ($powerTypeFlags as $k=>$v) {
                        $selected = isset($info['flag']) && $k == $info['flag'] ? 'selected="selected"' : '';
                        echo '<option value="' . $k . '" '.$selected.'>' . $v . '</option>';
                    }
                }
                ?>
            </select>
            <i class="hint">* (必选)</i>
        </div>
        <div class="form_item">
            <label>状态</label>
            <select name="status">
                <?php
                if(isset($statusArr)) {
                    foreach ($statusArr as $k=>$v) {
                        $selected = isset($info['status']) && $k == $info['status'] ? 'selected="selected"' : '';
                        echo '<option value="' . $k . '" '.$selected.'>' . $v . '</option>';
                    }
                }
                ?>
            </select>
            <i class="hint">* (必选)</i>
        </div>
        <div class="form_item">
            <label>排序</label>
            <input type="number" name="viewseq" value="<?php echo isset($info['viewseq']) ? $info['viewseq'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (必填)</i>
        </div>
        <div class="form_item">
            <label style="color:#ff7f77"> 编辑需保存 </label>
            <input type="button" id="sub_btn" value="提交保存" class="btn_base btn_back_sides btn_w300 btn_height35 btn_radius5">
        </div>
    </form>
</div>
</body>
<script language="javascript">
    var cssjsv = '<?php echo V_CSSJS;?>';
    var http_url = '<?php echo SYS_HOST;?>';
    var http_link = '<?php echo SYS_LINK;?>';
    var http_fix = '<?php echo SYS_URL_FIX;?>';
</script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/jquery.min.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/skin.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/common.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript">file_load('info');</script>
<script language="javascript">

    // 加载完毕后
    window.onload = function () {

    }

    // jquery
    var flagSub = true;
    var gotoUrl = '<?php echo SYS_URL_PATH('admin_power_updatefuns');?>';
    $(function(){
        $('#sub_btn').on('click',function(){
            if(!flagSub){
                layer.msg('处理中……(禁止重复提交)');return false;
            }
            flagSub = false;
            var fromBox = $('.form_box');
            var param = getFormData(fromBox);
            param.append('subFlag', 'Y'); // 追加参数
            $.ajax({
                url:gotoUrl,
                dataType:'json',
                type:'POST',
                async: false,
                data: param,
                processData : false, // 使数据不做处理
                contentType : false, // 不要设置Content-Type请求头
                success: function(data){
                    flagSub = true;
                    if(data=='Y'){
                        layer.msg('修改成功');
                        setTimeout(function(){
                            parent.location.reload();
                        },2500);
                    }else{
                        layer.msg('操作失败_'+data);
                    }
                },
                error:function(response){
                    flagSub = true;
                    layer.msg('网络异常');
                    console.log('网络异常：'+response);
                }
            });
        })
    })

    $('#menu_id').change(function(){
        let menuId = $(this).val();
        let n = Number(menuId);
        if (!isNaN(n)){
            $('#types').val(2); // 数字说明是菜单id
        }else{
            $('#types').val(3); // 不是数字说明是自定义类
        }
    })
</script>
</html>